package com.nineclock.sign.controller;

import com.nineclock.api.sign.SignDefinitionControllerApi;
import com.nineclock.common.entity.Result;
import com.nineclock.sign.dto.SignAllUserDTO;
import com.nineclock.sign.dto.SignDTO;
import com.nineclock.sign.service.SignPunchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class SignPunchController implements SignDefinitionControllerApi {
    @Autowired
    private SignPunchService signPunchService;
    @Override
    @PostMapping("/insert")
    public Result punch(SignDTO signDTO) {
       signPunchService.punch(signDTO);
        return Result.success();
    }

    @Override
    @GetMapping("/listSignAllUser")
    public Result<List<SignAllUserDTO>> queryMembers( @RequestParam(value = "dateStr")String dateStr) {
        List<SignAllUserDTO> list = signPunchService.queryMembers(dateStr);
        return Result.success(list);
    }

    //获取当前员工当日的签到次数
    @Override
    @GetMapping("/getDayCount")
    public Result getDayCount() {

        Integer dayCount = signPunchService.getDayCount();
        return Result.success(dayCount);
    }

    //查询本月签到记录
    @GetMapping("/pagingSignCurrentUserByMonth")
    @Override
    public Result<List<SignDTO>> pagingSignCurrentUserByMonth(String dateStr) {
        List<SignDTO> signDTOS = signPunchService.pagingSignCurrentUserByMonth(dateStr);
        return Result.success(signDTOS);
    }

}
